cmake_minimum_required(VERSION 2.6)
project(FAN_LLVM CXX)

# Find LLVM
find_program(LLVM_CONFIG llvm-config)
if(LLVM_CONFIG)
  execute_process(
    COMMAND ${LLVM_CONFIG} --cxxflags
    OUTPUT_VARIABLE LLVM_CXXFLAGS
    OUTPUT_STRIP_TRAILING_WHITESPACE
  )
  execute_process(
    COMMAND ${LLVM_CONFIG} --includedir
    OUTPUT_VARIABLE LLVM_INCLUDEDIR
    OUTPUT_STRIP_TRAILING_WHITESPACE
  )
  execute_process(
    COMMAND ${LLVM_CONFIG} --ldflags
    OUTPUT_VARIABLE LLVM_LDFLAGS
    OUTPUT_STRIP_TRAILING_WHITESPACE
  )
  execute_process(
    COMMAND ${LLVM_CONFIG} --libfiles bitwriter linker ipo instrumentation backend jit
    OUTPUT_VARIABLE LLVM_LIBS
    OUTPUT_STRIP_TRAILING_WHITESPACE
  )
else()
  message(FATAL_ERROR "llvm not found")
endif()

# Find the "core" and "sys" packages of fan-llvm
find_package(FanLLVMCore REQUIRED)
find_package(FanLLVMSys REQUIRED)

add_subdirectory(src)
